package com.example.demo.mapper;

import com.example.demo.pojo.Emp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {
    // 动态sql
    long selectEmpsCountByCondition(String name, Byte gender, LocalDate begin, LocalDate end);

    // 动态sql
    List<Emp> selectEmpsByCondition(String name, Byte gender, LocalDate begin, LocalDate end, int startIndex, int pageSize);

    // 动态sql
    List<Emp> deleteEmpsById(Integer[] ids);

    @Insert("insert into emp(username,name,gender,image,job,entrydate,dept_id,create_time,update_time) " +
            "values(#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime});")
    int insertEmps(Emp emp);

    @Update("update emp set username=#{username},name=#{name},gender=#{gender},image=#{image}," +
            "job=#{job},entrydate=#{entrydate},dept_id=#{deptId},update_time=#{updateTime} where id=#{id}")
    int updateEmps(Emp emp);


    @Select("select * from emp where id=#{id}")
    Emp selectById(Integer id);
}
